fix(core): harden file permissions for user config directory#328
Merged
Conversation
Sensitive files in the OpenShell config directory (~/.config/openshell/) were created with default umask permissions, making them world-readable. This is a security concern for mTLS private keys (tls.key) and auth tokens. - Add centralized paths module to openshell-core with permission helpers (create_dir_restricted 0o700, set_file_owner_only 0o600) - Set 0o600 on tls.key in mtls.rs (was inheriting umask, typically 0o644) - Set 0o700 on all config directories (mtls/, gateways/, forwards/, etc.) - Migrate legacy cf_token files to new edge_token path with proper perms - Deduplicate xdg_config_dir() from 6 locations into openshell-core
d1af0a5 to
850c387
Compare
drew
added a commit
that referenced
this pull request
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sensitive files in the OpenShell config directory (
~/.config/openshell/) were created with default umask permissions (typically0o644for files,0o755for directories), making mTLS private keys and auth tokens world-readable on multi-user systems.Changes
openshell_core::pathsmodule with centralized XDG config resolution and permission helpers (create_dir_restricted0o700,set_file_owner_only0o600,is_file_permissions_too_open)mtls.rs):tls.keynow set to0o600immediately after writing; temp and finalmtls/directories created with0o700openshell/,gateways/<name>/,forwards/, SSH config parent -- all created with0o700viacreate_dir_restrictedload_edge_token()now migrates legacycf_tokenfiles to the newedge_tokenpath with proper0o600permissions and removes the insecure legacy filexdg_config_dir()implementations acrossopenshell-bootstrap,openshell-cli,openshell-core, andopenshell-tuiwith a single canonical version inopenshell-core::pathsTesting
mise run pre-commitpasses (format fixed, one pre-existing test failure unrelated -- port 8080 occupied locally)create_dir_restricted_sets_0o700,set_file_owner_only_sets_0o600,is_file_permissions_too_open_*)Checklist